package com.rmfyzxfw.caseprocess.model.vo;

import com.alibaba.fastjson.JSONObject;
import com.rmfyzxfw.caseprocess.model.cmd.ProcessNodeCmd;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @description:
 * @Author: GYW  742926306@qq.com
 * @Date: 2024/8/6 17:32
 */
@Data
public class ProcessNodeVO {
    /**
     * 两种方式  一种是排序字段  一种是直接取get(0)
     */
    @ApiModelProperty(value ="排序")
    private int sort;

    @ApiModelProperty(value ="流程节点id")
    private String processNodeId;

    @ApiModelProperty(value ="流程节点名称 不可重复")
    private String processNodeName;
    /**
     * 表达式与或非   (A && B && C) || D
     */
    @ApiModelProperty(value ="规则表达式")
    private String ruleExpression;

    @ApiModelProperty(value ="是否要完成所有节点")
    private Boolean finishAll;

    @ApiModelProperty(value ="数据节点")
    private List<DataNodeVO> dataNodes;

    /**
     * 数据节点
     */
    @Data
   public static class DataNodeVO {
        @ApiModelProperty(value ="数据节点id")
        private String dataNodeId;

        @ApiModelProperty(value ="数据节点名称")
        private String dataNodeName;

        @ApiModelProperty(value ="流程节点选中的状态id")
        private String statusId;

        @ApiModelProperty(value ="子流程id")
        private String childrenProcessId;

        @ApiModelProperty(value ="数据节点各状态配置")
        private List<DataNodeStatusVO> dataNodeStatuses;

        private Integer sort;

    }

    @Data
    public static class DataNodeStatusVO {
        private String color;

        private String statusName;
        private String statusId;
        private Integer statusLevel;

        /**
         * 表达式与或非   (A && B && C) || D
         */
        @ApiModelProperty(value ="规则表达式 为空表示流程节点触发即可")
        private String ruleExpression;
        /**
         * 数据字段 或者是节点
         */
        @ApiModelProperty(value ="数据字段 或者是节点")
        private List<NodeFieldVO> nodeFields;

        /**
         * 运算项  A B C 等等 自动生成  每个node唯一
         */
        @ApiModelProperty(value ="运算项  A B C 等等 自动生成  每个node唯一")
        private String operationItem;
    }
    @Data
    public static class NodeFieldVO {
        @ApiModelProperty(value ="1 数据项  2 节点")
        private Integer type;

        @ApiModelProperty(value ="运算项  A B C 等等 自动生成  唯一")
        private String operationItem;

        /*数据项*/
        @ApiModelProperty(value ="数据项名称")
        private String itemName;

        @ApiModelProperty(value ="数据源id")
        private String dynamicDataSourceId;
        @ApiModelProperty(value ="数据项id")
        private String dataItemId;

        @ApiModelProperty(value ="表名")
        private String tableName;

        @ApiModelProperty(value ="字段英文名")
        private String fieldNameEn;

        @ApiModelProperty(value ="字段中文名")
        private String fieldNameCn;

        @ApiModelProperty(value ="字段值")
        private JSONObject fieldTargetValue;

        @ApiModelProperty(value ="字段值类型  1 文本  2 数字  3 日期（年月日）")
        private Integer fieldValueType;
        /*end数据项*/

        /*节点*/
        @ApiModelProperty(value ="运算符  暂时 = >= > < <=")
        private String operator;

        @ApiModelProperty(value ="子流程")
        private ProcessNodeCmd.ChildrenProcess childrenProcess;

        @ApiModelProperty(value ="子流程id 有值代表节点是子流程")
        private String childrenProcessId;

        @ApiModelProperty(value ="数据节点id")
        private String dataNodeId;

        private String statusId;
        @ApiModelProperty(value ="节点点亮天数")
        private Integer lightDays;

        @ApiModelProperty(value ="数据节点名称")
        private String dataNodeName;
        /*end节点*/

        /*前端回显使用*/
        private Integer groupId;
        private Integer groupLogic;
        private Integer logic;
        private Integer sort;
        private Integer groupSort;
        private String fieldId;
        /*end前端回显使用*/
    }

    @Data
    public static class ChildrenProcess{
        @ApiModelProperty(value =" 如果是从子流程获取的节点需传子流程id")
        private String childrenProcessId; //使用者树

        @ApiModelProperty(value ="数据节点id")
        private String dataNodeId;
        @ApiModelProperty(value ="数据节点名称")
        private String dataNodeName;

        private ProcessNodeCmd.ChildrenProcess childrenProcess;
    }
}